package com.lad.springboot_mybatis.controller;

import com.lad.springboot_mybatis.entity.User;
import com.lad.springboot_mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:wjup
 * @Date: 2018/9/26 0026
 * @Time: 14:42
 */
 
@RestController
@RequestMapping("/testBoot")
public class UserController {
 
    @Autowired
    private UserService userService;
 
    @RequestMapping("getUser/{id}")
    public String GetUser(@PathVariable int id){
        return userService.Sel(id).toString();
    }
    @RequestMapping("selectUser/{name}")
    public String selectUser(@PathVariable String name){
        return userService.selectUserByName(name).toString();
    }
    @RequestMapping("cacheUser/{id}")
    public String cacheUser(@PathVariable String id){
        return userService.selectUserByCache(id).toString();
    }

    @RequestMapping("/update")
    public void update(){
        userService.update();
    }

    @PostMapping("/saveUser")
    public void saveUser(@RequestBody User user) {
        System.out.println(user);
    }

    @GetMapping("/save")
    public String save() {
        userService.saveA();
        return "ok";
    }
}